package com.hainatong.jcmvvmbase.mainhome.fragment;

import android.os.Bundle;
import android.view.View;
import androidx.recyclerview.widget.LinearLayoutManager;
import com.blankj.utilcode.util.ToastUtils;
import com.hainatong.jcmvvmbase.Constants;
import com.hainatong.jcmvvmbase.MvvmLazyFragment;
import com.hainatong.jcmvvmbase.R;
import com.hainatong.jcmvvmbase.databinding.FragmentListViewBinding;
import com.hainatong.jcmvvmbase.mainhome.ComFragmentActivity;
import com.hainatong.jcmvvmbase.mainhome.adapter.SubFunctionAdapter;
import com.hainatong.jcmvvmbase.mainhome.entity.FunctionEntity;
import com.hainatong.jcmvvmbase.mainhome.fragment.holiday.NormalHolidayFragment;
import com.hainatong.mvvmbase.base.NoViewModel;

import java.util.ArrayList;
import java.util.List;

public class HolidayMgrFragment extends MvvmLazyFragment<FragmentListViewBinding, NoViewModel>
{
    private SubFunctionAdapter adapter;

    @Override
    public int getLayoutId()
    {
        return R.layout.fragment_list_view;
    }

    @Override
    public int getBindingVariable()
    {
        return 0;
    }

    @Override
    protected void onRetryBtnClick()
    {

    }

    @Override
    protected void initView(View view)
    {
        adapter = new SubFunctionAdapter();
        viewDataBinding.recyclerview.setLayoutManager(new LinearLayoutManager(getActivity()));
        viewDataBinding.recyclerview.setHasFixedSize(true);
        viewDataBinding.recyclerview.setAdapter(adapter);
        List<FunctionEntity> funList = new ArrayList<>();
        funList.add(new FunctionEntity(getString(R.string.zhengchang_xiujia),""+Constants.FUN_ZHENGCHANGXIUJIA,R.mipmap.ic_holiday));
        funList.add(new FunctionEntity(getString(R.string.linshi_xiujia),""+Constants.FUN_LINSHIXIUJIA,R.mipmap.ic_temp_holiday));
        funList.add(new FunctionEntity(getString(R.string.yanqi_xiujia),""+Constants.FUN_YANQIXIUJIA,R.mipmap.ic_delay_holiday));
        funList.add(new FunctionEntity(getString(R.string.zhengshu_xiujia),""+Constants.FUN_GENGHUANXIUJIA,R.mipmap.ic_certificate_holiday));
        funList.add(new FunctionEntity(getString(R.string.can_not_job),""+Constants.FUN_NOTWORK,R.mipmap.ic_resign));
        adapter.setList( funList );
        adapter.setOnItemClickListener((adapter1, view1, position) -> {

            Bundle bundle = new Bundle();
            switch ( Integer.parseInt( adapter.getItem(position).getContentTag() ) )
            {

                case Constants.FUN_ZHENGCHANGXIUJIA:

                    bundle.putString( Constants.FRAGMNET_TYPE, Constants.VIEW_NORMAL_HOLIDAY);
                    bundle.putString(Constants.SCAN_CONTENT_CODE,""+ NormalHolidayFragment.normalHolidayType);
                    ComFragmentActivity.start( getActivity(),bundle );
                    break;
                case Constants.FUN_LINSHIXIUJIA:

                    bundle.putString( Constants.FRAGMNET_TYPE, Constants.VIEW_NORMAL_HOLIDAY);
                    bundle.putString(Constants.SCAN_CONTENT_CODE,""+ NormalHolidayFragment.tempHolidayType);
                    ComFragmentActivity.start( getActivity(),bundle );
                    break;
                case Constants.FUN_YANQIXIUJIA:

                    bundle.putString( Constants.FRAGMNET_TYPE, Constants.VIEW_NORMAL_HOLIDAY);
                    bundle.putString(Constants.SCAN_CONTENT_CODE,""+ NormalHolidayFragment.delayHolidayType);
                    ComFragmentActivity.start( getActivity(),bundle );
                    break;
                case Constants.FUN_GENGHUANXIUJIA:
                    bundle.putString( Constants.FRAGMNET_TYPE, Constants.VIEW_NORMAL_HOLIDAY);
                    bundle.putString(Constants.SCAN_CONTENT_CODE,""+ NormalHolidayFragment.changeHolidayType);
                    ComFragmentActivity.start( getActivity(),bundle );
                    break;
                case Constants.FUN_NOTWORK:
                    bundle.putString( Constants.FRAGMNET_TYPE, Constants.VIEW_NO_JOB);
                    ComFragmentActivity.start( getActivity(),bundle );
                    break;
            }
            //ToastUtils.showShort( adapter.getItem(position).getTitle() );

        });
    }
}
